package class6;


/**
 * 题目：将十进制数字转换成二进制
 * 13 = 1101
 */
public class Code03_DecimalToBinary {
    public static void main(String[] args) {
        int i = 12;
        String value = getBinaryValue(i);
        System.out.println(value);
    }

    public static String getBinaryValue(int x) {
        StringBuilder sb = new StringBuilder();
        while (x != 0) {
            sb.insert(0,x & 1);
            x >>>= 1;
        }
        return sb.toString();
    }
}
